import Vue from 'vue';
import Router from 'vue-router';

import Login from '@/views/Login.vue';
import shelfManage from '@/views/system/shelfManage.vue';
import Home from '@/views/layout/Home.vue';
import MainContent from '@/views/layout/MainContent.vue';
import UserManagement from '@/views/system/UserManagement/UserManagement.vue';
import viewPort from '@/views/viewPort.vue';


Vue.use(Router);

export default new Router({
    mode: 'history',
    routes: [
        {
            path: '/login',
            component: Login
        },
        {
            path: '/viewPort',
            component: viewPort
        },
        {
            path: '*',
            redirect: '/login'
        },
        {
            path: '/',
            component: Home,
            children: [
                {
                    path: '',
                    name: 'Dashboard',  // 首页仪表盘
                    component: MainContent
                },
                {
                    path: '/system/shelfManage',
                    name: 'shelfManage',
                    component: shelfManage
                },
                {
                    path: 'system/UserManagement/UserManagement',
                    name: 'UserManagement',
                    component: UserManagement
                }
            ]
        }
    ]
});
//
// router.beforeEach((to, from, next) => {
//     const userInfo = JSON.parse(localStorage.getItem('userInfo'));
//     if (to.path !== '/login' && !userInfo) {
//         return next('/login');
//     }
//     next();
// });
